/**
 * Created by 功振 on 2016/1/30.
 */
angular.module('NatureCloud').factory('utilService',function () {
    var util = {
        copyProperties: function (srcObj, tarObj) {
            //var tarObj = {};
            var i;
            for (i in srcObj) {
                tarObj[i] = srcObj[i];
            }
            //return tarObj;
        },
        sortByFieldApp:function(a,b){
            return a.app > b.app;
        },
        getVersionFromImg:function(image){
            var _ver = '';
            var _idx = image.lastIndexOf('/');
            if(_idx != -1){
                var ret = image.substr(_idx+1);
                _idx = ret.lastIndexOf(':');
                if(_idx!= -1)
                    _ver = ret.substr(_idx+1);
            }
            return _ver;
        },
        deepCopyObj:function(source){
            var result={};
            for (var key in source) {
                if(Object.prototype.toString.call(source[key])==='[object Object]')
                    result[key] = this.deepCopyObj(source[key]);
                else if(Object.prototype.toString.call(source[key])==='[object Array]')
                    result[key] = source[key].slice();
                else
                    result[key]  = source[key];
            }
            return result;
        },
        simpleEqualObj:function(a,b){
            return a._id === b._id
        }


}
    return util;
});